home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_actor_robotboss.cog < prev    next >
Text File  |  1999-11-15  |  8KB  |  303 lines

  1. # Jones 3D Cog Script
  2. #
  3. # actor_RobotBoss.cog
  4. #
  5. # [MDR]
  6. #
  7. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. # ===================================================================
  10.  
  11. symbols
  12.  
  13. message        startup
  14. message        created
  15. message        aievent
  16. message        timer
  17. message        damaged
  18. message        callback
  19.  
  20. # ************************** TEMPLATES *************************
  21. template    tpl_PrimaryWeapon=+robohit_lg        local
  22. template    tpl_AltWeapon=+robohit_lasr            local
  23. template    tpl_Statue=robodead                    local
  24.  
  25. template    tpl_arcs=rbossElecArc                local
  26. template    tpl_sparks0=rbossSparks                local
  27. template    tpl_sparks1=rbossFntnMD                local
  28. template    tpl_sparks2=lbossSparksMD            local
  29.  
  30. template    tpl_explode=+lava_guy_fire            local
  31. template    tpl_smoke=+lava_guy_smoke            local
  32.  
  33. material    mat_glow=nub_a4sfx_rboss_hit.mat    local
  34.  
  35. # ************************** WEAPON HANDLERS *******************
  36. vector        vec_primaryOffset                local
  37. vector        vec_AltOffset                    local
  38.  
  39. # ************************** SPECIAL FX ************************
  40. int            n_joint00                        local
  41. int            n_joint01                        local
  42. int            n_joint02                        local
  43. int            n_joint03                        local
  44. int            n_joint04                        local
  45. int            n_joint05                        local
  46. int            n_joint06                        local
  47. int            n_joint07                        local
  48. int            n_joint08                        local
  49. int            n_joint09                        local
  50.  
  51. # ************************** MISC LOCAL VARS *******************
  52. thing        t_boss                            local
  53. thing        t_player                        local
  54. flex        f_scale                            local
  55.  
  56. int            TIMERID_HANDSPARKS=1            local
  57.  
  58. int            n_eventType                        local
  59. int            n_crntAIMode                    local
  60. int            n_param                            local
  61.  
  62. int            n_sndFootMove=-1                local
  63.  
  64. int            n_idx                            local
  65. int            n_numSparks                        local
  66. flex        f_sleepTime                        local
  67. flex        f_val                            local
  68.  
  69. vector        vec_pos                            local
  70.  
  71. end
  72.  
  73. # ===================================================================
  74. code
  75.  
  76. # ...................................................................
  77. startup:
  78.  
  79.     MaterialAnim(mat_glow, 12, 1);
  80.  
  81.     return;
  82.  
  83.  
  84. # ...................................................................
  85. created:
  86.  
  87.     t_player            = GetLocalPlayerThing();
  88.     t_boss                = GetSenderRef();
  89.  
  90.     vec_altOffset        = VectorSet(0.0, 0.19, 0.15);
  91. #    vec_primaryOffset    = VectorSet(0.0, 0.20, 0.0);
  92.     SetThingFireoffset(t_boss, '0 0 0');
  93.  
  94.     AISetMode(t_boss, 0x2000000);                            # Set MODE_NOCHASING
  95.     AISetSubMode(t_boss, 0x80040);                            # Set SUBMODE_(SLOWMODEFADE|FIREADDEYEOFFSET)
  96.     AISetSubMode(t_boss, 0x1000000);                        # Set SUBMODE_SPECIALTURNS
  97.  
  98.     SetThingMoveSize(t_boss, 0.18);
  99.     AISetInstinctWpntMode(t_boss);
  100.  
  101.     SetPuppetModeFPS(t_boss, 0, 40, 15);                    # Slow down '180 turn' anim
  102.     SetPuppetModeFPS(t_boss, 0, 75, 20);                    # Slow down 'hit' anim
  103.  
  104.     n_joint00 = GetNodeByName(t_boss, "rbeye");
  105.  
  106.     n_joint01 = GetNodeByName(t_boss, "rblshdr");
  107.     n_joint02 = GetNodeByName(t_boss, "rblarm");
  108.     n_joint03 = GetNodeByName(t_boss, "rblwrist");
  109.  
  110.     n_joint04 = GetNodeByName(t_boss, "rbrshdr");
  111.     n_joint05 = GetNodeByName(t_boss, "rbrarm");
  112.     n_joint06 = GetNodeByName(t_boss, "rbrwrist");
  113.  
  114.     n_joint07 = GetNodeByName(t_boss, "rbhip");
  115.     n_joint08 = GetNodeByName(t_boss, "rblleg");
  116.     n_joint09 = GetNodeByName(t_boss, "rbrleg");
  117.  
  118.     return;
  119.  
  120.  
  121. # ...................................................................
  122. aievent:
  123.  
  124.     t_boss        = GetSenderRef();
  125.     n_eventType    = GetParam(0);
  126.     n_param        = GetParam(2);                                # Value depends on n_eventType
  127.  
  128.     if ( n_eventType == 0x100 )                                #---- SITHAI_EVENTMODECHANGED
  129.     {
  130.         n_crntAIMode = GetParam(1);
  131.         if ( BITTEST(n_crntAIMode, 0x01) && !BITTEST(n_param, 0x01) )        # Started moving?
  132.         {
  133.             vec_pos = AIGetMovePos(t_boss);
  134.             vec_pos = VectorSub(vec_pos, GetThingPos(t_boss));
  135.             if ( VectorLen(vec_pos) > 0.15 )
  136.             {
  137.                 n_sndFootMove = PlaySoundClass(t_boss, 3);                    # play 'startmove'
  138.             }
  139.         }
  140.     }
  141.     else if ( BITTEST(n_eventType, 0x80800 ) )                #---- EVENT_GOAL(UNREACHABLE|REACHED)
  142.     {
  143.         if ( n_sndFootMove > -1 )
  144.         {
  145.             StopSound(n_sndFootMove, 0.2);
  146.             n_sndFootMove = -1;
  147.         }
  148.     }
  149.     else if ( n_eventType == 0x10000 )                        #---- EVENT_PREFIRE
  150.     {
  151.         if ( BITTEST(n_param, 0x0020) )                            # SITHAIUTIL_FIRE_ALT
  152.         {
  153.             SetActorWeapon(t_boss, tpl_AltWeapon);                # Swap to alternate weapon
  154.             SetThingFireoffset(t_boss, vec_altOffset);
  155.         }
  156.     }
  157.     else if ( n_eventType == 0x4000 )                        #---- EVENT_FIRE
  158.     {
  159.         if ( IsModePlaying(t_boss, 65) )
  160.         {
  161.             SetTimerEx(0.3, TIMERID_HANDSPARKS, 6, 0);
  162.         }
  163.     }
  164.     else if ( n_eventType == 0x20000 )                        #---- EVENT_POSTFIRE
  165.     {
  166.         SetActorWeapon(t_boss, tpl_primaryWeapon);                # reset primary weapon
  167.         SetThingFireoffset(t_boss, '0 0 0');
  168.     }
  169.  
  170.     return;
  171.  
  172.  
  173. # ...................................................................
  174. timer:
  175.  
  176.     n_param = GetParam(0) - 1;
  177.  
  178.     if ( GetSenderID() == TIMERID_HANDSPARKS )
  179.     {
  180.         if ( Rand() > 0.5 )
  181.         {
  182.             vec_pos = GetThingJointPos(t_boss, n_joint06);
  183.             CreateThingAtPos(tpl_sparks0, FindNewSectorFromThing(t_boss, vec_pos), vec_pos, '0 0 0');
  184.         }
  185.         else
  186.         {
  187.             vec_pos = GetThingJointPos(t_boss, n_joint03);
  188.             CreateThingAtPos(tpl_sparks0, FindNewSectorFromThing(t_boss, vec_pos), vec_pos, '0 0 0');
  189.         }
  190.  
  191.         if ( n_param > 0 )
  192.         {
  193.             SetTimerEx(0.15, TIMERID_HANDSPARKS, n_param, 0);
  194.         }
  195.     }
  196.  
  197.     return;
  198.  
  199.  
  200. # ...................................................................
  201. damaged:
  202.  
  203.     n_param = GetParam(1);
  204.     if (n_param != 0x100000)                                #---- If not SITH_DAMAGE_LIGHTNING, clear damage
  205.     {
  206.         if ( BITTEST(n_param, 0x01) )                            # DAMAGE_IMPACT?
  207.         {
  208.             PlaySoundClass(t_boss, 85);                            # Play ricochet sound
  209.         }
  210.  
  211.         ReturnEx(0);                                            # Reduce damage to Nil
  212.         return;
  213.     }
  214.  
  215.     if ( GetThingHealth(t_boss)-GetParam(0) <= 0 )            #---- Death!!  Make lots of sparks
  216.     {
  217.         n_numSparks = 24;
  218.         f_sleepTime = 0.2;
  219.     }
  220.     else                                                    #---- Ouch!  Make some sparks
  221.     {
  222.         n_numSparks = 6;
  223.         f_sleepTime = 0.4;
  224.     }
  225.     for ( n_idx=0; n_idx < n_numSparks; n_idx = n_idx + 1 )
  226.     {
  227.         vec_pos = GetThingJointPos(t_boss, n_joint00[RandBetween(0, 9)]);
  228.         CreateThingAtPos(tpl_sparks1, FindNewSectorFromThing(t_boss, vec_pos), vec_pos, '0 0 0');
  229.  
  230.         vec_pos = GetThingJointPos(t_boss, n_joint00[RandBetween(0, 9)]);
  231.         CreateThingAtPos(tpl_sparks1, FindNewSectorFromThing(t_boss, vec_pos), vec_pos, '0 0 0');
  232.         CreateThingAtPos(tpl_arcs, FindNewSectorFromThing(t_boss, vec_pos), vec_pos, '0 0 0');
  233.  
  234.         PlaySoundClass(t_boss, 89);                                # Play 'hitdamaged' sound
  235.  
  236.         Sleep(f_sleepTime);
  237.     }
  238.  
  239.     return;
  240.  
  241.  
  242. # ...................................................................
  243. callback:
  244.  
  245.     t_boss     = GetSenderRef();
  246.     t_player = GetLocalPlayerThing();
  247.     n_param  = GetParam(1);
  248.  
  249.     if (n_param == 16)                                        #---- Death anim callback
  250.     {
  251.         Reset();
  252.  
  253.          vec_pos = GetThingJointPos(t_boss, n_joint00);
  254.         vec_pos = VectorAdd(vec_pos, VectorTransformToOrient(t_boss, '0.0 0.08 -0.05'));
  255.         CreateThingAtPos(tpl_explode, FindNewSectorFromThing(t_boss, vec_pos), vec_pos, '0 0 0');
  256.         CreateThingAtPos(tpl_smoke, FindNewSectorFromThing(t_boss, vec_pos), vec_pos, '0 0 0');
  257.  
  258.         for ( n_idx=0; n_idx < 10; n_idx = n_idx + 1 )
  259.         {
  260.             CreateThingAtPos(tpl_sparks2, FindNewSectorFromThing(t_boss, vec_pos), vec_pos, '0 0 0');
  261.         }
  262.  
  263.         PlaySoundClass(t_boss, 124);                            # go boom
  264.  
  265.         CreateThing(tpl_Statue, t_boss);
  266.         DestroyThing(t_boss);
  267.         return;
  268.     }
  269.  
  270.     if (n_param == 21)                                        #---- Right foot down
  271.     {
  272.         vec_pos        = VectorSet(10.0, 0, -5.0);
  273.         f_scale        = 0.5 / VectorDist( GetThingPos(t_boss), GetThingPos(t_player) );
  274.         SetPOVShake('0 0 0', VectorScale(vec_pos, f_scale), 0.0, 55.0);
  275.  
  276.         PlaySoundClass(t_boss, 6);                                # play 'lwalkhard'
  277.     }
  278.     else if (n_param == 22)                                    #---- Start moving left foot
  279.     {
  280.         n_sndFootMove = PlaySoundClass(t_boss, 46);                # play 'lwalkaet'
  281.     }
  282.     else if (n_param == 23)                                    #---- Left foot down
  283.     {
  284.         vec_pos        = VectorSet(10.0, 0, 5.0);
  285.         f_scale        = 0.5 / VectorDist( GetThingPos(t_boss), GetThingPos(t_player) );
  286.         SetPOVShake('0 0 0', VectorScale(vec_pos, f_scale), 0.0, 55.0);
  287.  
  288.         PlaySoundClass(t_boss, 7);                                # play 'rwalkhard'
  289.     }
  290.     else if (n_param == 24)                                    #---- Start moving right foot
  291.     {
  292.         n_sndFootMove = PlaySoundClass(t_boss, 47);                # play 'rwalkaet'
  293.     }
  294.     else if (n_param == 25)                                    #---- Start 180 turn sound
  295.     {
  296.         PlaySoundClass(t_boss, 123);                            # play 'reserved1'
  297.     }
  298.     
  299.     return;
  300.  
  301. end
  302.  
  303.